<template>
	<view>
		<view class="group_buying_box">
			<view class="flex_start group_title">
				<view class="">这些人刚刚开团 可参与拼团</view>
			</view>
			<view class="flex_start group_title">
				<view class="flex_start img_box">
					<image src="../../../static/img/default.png" class="group_default" mode="" v-for="(img, index) in employInfo.groupData" :key="index"></image>
				</view>
				<view class="flex_start group_btns" @click="joinGroup">去参团</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				employInfo: {}
			};
		},
		onLoad(option) {
			this.type = option.type
			this.employInfo = uni.getStorageSync('objs')
			console.log(this.employInfo)
			uni.removeStorageSync('objs')
		},
		methods:{
			joinGroup(){
				if (this.type == 'public') {
					this.$utils.requert({ url: 'recruitGroupJoin', data: { 
						recruitId: this.employInfo.id,
						groupId: this.employInfo.groupData[0].groupId
						}, type: 'post' }).then(res => {
						if (res.code === 1) {
							this.$utils.showLayer(res.message);
							uni.navigateBack({
								delta:1
							})
						} else {
							this.$utils.showLayer(res.message);
							this.$refs.popup.close();
						}
					});
				}else if(this.type =='realtime'){ //实时用工
					this.$utils.requert({ url: 'timeOrderGroupJoin', data: { 
						orderId: this.employInfo.id,
						groupId: this.employInfo.groupData[0].groupId
						}, type: 'post' }).then(res => {
						if (res.code === 1) {
							this.$utils.showLayer(res.message);
							uni.navigateBack({
								delta:1
							})
						} else {
							this.$utils.showLayer(res.message);
							this.$refs.popup.close();
						}
					});
				}
			}
		}
	}
</script>

<style lang="scss">
.group_buying_box{
		font-size: 28rpx;
		padding: 30rpx;
		.group_default{
			width: 80rpx;
			height: 80rpx;
			flex-shrink: 0;
			border-radius: 50%;
			margin-left: -30rpx;
			border: 2rpx solid #CCCCCC;
		}
		.img_box{
			box-sizing: border-box;
			margin-left: 30rpx;
		}
		.group_btns{
			border-radius: 8rpx;
			background: red;
			justify-content: center;
			color: white;
			padding: 4rpx 12rpx;
		}
		.group_title{
			justify-content: space-between;
			height: 98rpx;
			.get_more{
				color: #666666;
				font-size: 26rpx;
			}
		}
	}
</style>
